#ifndef __PROJECT_FIFO_PRO_H__
#define __PROJECT_FIFO_PRO_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>

typedef uint32_t queuetype;
struct queueArrayInformStruct
{
    uint8_t *saveBuf; // 缓冲区
    queuetype windex;
    queuetype rindex;
    queuetype bufLen;
};

#ifndef CYCLE_ADD
#define CYCLE_ADD(a, add, len) (((a) + (add)) % (len))
#endif

#define queArrayDeine(queName, queSize)    \
    uint8_t queName##SaveBuffer[queSize]; \
    struct queueArrayInformStruct queName = {queName##SaveBuffer, 0, 0, queSize};

void queueArrayInit(struct queueArrayInformStruct *finf, uint8_t *usrp, queuetype savelen);
void queueArrayInputString(struct queueArrayInformStruct *finf, const uint8_t *inbuf, queuetype len);
queuetype queueArraySize(struct queueArrayInformStruct *finf);
queuetype queueArrayGetString(struct queueArrayInformStruct *finf, uint8_t *outbuf, queuetype len);
queuetype queueArrayGetFixedSizeString(struct queueArrayInformStruct *finf, uint8_t *outbuf, queuetype len);
#endif
